//
//  NewDeviceIconCell.m
//  YSSmartHome
//
//  Created by yanghao on 2016/10/9.
//  Copyright © 2016年 yahaong. All rights reserved.
//

#import "NewDeviceIconCell.h"
#import "YHMarcros.h"

@interface NewDeviceIconCell ()
@property(nonatomic, strong)UIImageView *iconView;
@property(nonatomic, strong)UIImageView *selectedView;
@end
@implementation NewDeviceIconCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.iconView];
        [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.contentView);
            make.width.equalTo(kIphoneSize_Widith(100));
            make.height.equalTo(kIphoneSize_Height(84));
        }];
        [self.contentView addSubview:self.selectedView];
        [self.selectedView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(10);
            make.trailing.equalTo(self.contentView).offset(-10);
            make.width.equalTo(28);
            make.height.equalTo(28);
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected
{
    [super setSelected:selected];
    self.selectedView.hidden = !selected;
}
- (void)setIcon:(NSString *)icon
{
    _icon = [icon copy];
    self.iconView.image = [UIImage imageNamed:icon];
}
#pragma mark - lazy loading

- (UIImageView *)selectedView
{
    if (!_selectedView) {
        _selectedView = [[UIImageView alloc]init];
        _selectedView.image = [UIImage imageNamed:@"scene_condition_selected"];
        _selectedView.hidden = YES;
    }
    return _selectedView;
}

- (UIImageView *)iconView
{
    if (!_iconView) {
        _iconView = [[UIImageView alloc]init];
    }
    return _iconView;
}
@end
